package com.jd.fruit.controller.admin.shop;

import java.io.IOException;
import java.util.List;

import com.jd.fruit.common.annotation.Controller;
import com.jd.fruit.common.controller.BaseController;
import com.jd.fruit.common.util.DictUtil;
import com.jd.fruit.common.util.StringUtil;
import com.jd.fruit.model.admin.order.Address;
import com.jd.fruit.model.admin.shop.Attribute;
import com.jfinal.plugin.activerecord.Page;
/**
 * 订单地址管理
 * @author admin
 *
 */
@Controller("/admin/shop/address")
public class AddressController extends BaseController {
	/**
	 *订单地址保存信息
	 */
	public void save() {
		Address address = getModel(Address.class);
		Address.dao.save(address);
		this.redirect("/admin/shop/order/list");
	}
	/**
	 * 订单地址列表
	 */
	public void list(){
		int pageNumber = this.getParaToInt(0,1);
		Page<Address> addresslist = Address.dao.list(pageNumber,DictUtil.default_pageSize);
		this.getRequest().setAttribute("addresslist", addresslist);
		render("address_list.html");
	}
	/**
	 * 订单地址删除
	 * 
	 * @throws IOException
	 */
	public void delete() throws IOException {
		String id = StringUtil.getDcodePara(getRequest(), "id");

			boolean isOk = Address.dao.deleteById(id);
			if (isOk) {// success
				this.renderText(DictUtil.success);
			} else { // failed
				this.renderText(DictUtil.failed);
			}
	}	 
}
